home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
dev
/
e
/
amigae21b.lha
/
Amiga_E_v2.1b
/
Sources
/
Utilities
/
Watch.e
< prev
next >
Wrap
Text File
|
1992-09-02
|
1KB
|
36 lines
/* Watch a file by notification
pops up a requester when a file gets modified.
USAGE: watch <file>
EXAMPLE: run >NIL: watch >NIL: s:startup-sequence */
OPT OSVERSION=37
MODULE 'dos/notify'
DEF nreq:PTR TO notifyrequest,sig,task,exists
PROC main() /* make sure file is there: else we'll */
IF (FileLength(arg)=-1) OR (arg[0]=0) /* never be notified */
WriteF('file "\s" does not exist\n',arg)
CleanUp(10)
ENDIF
nreq:=New(SIZEOF notifyrequest) /* memory is cleared */
IF nreq=NIL THEN RETURN 20
sig:=AllocSignal(-1) /* we want to be signalled */
IF sig=-1 THEN RETURN 10
task:=FindTask(0)
nreq.name:=arg /* fill in structure */
nreq.flags:=NRF_SEND_SIGNAL
nreq.port:=task /* union port/task */
nreq.signalnum:=sig
IF StartNotify(nreq)
WriteF('Now watching: "\s"\n',arg)
Wait(Shl(1,sig))
EasyRequestArgs(0,[20,0,0,'File "\s" modified!','Damn!'],0,[arg])
EndNotify(nreq)
ELSE
WriteF('Could not watch "\s".\n',arg)
ENDIF
FreeSignal(sig)
ENDPROC